package com.genghis.ptas.note.service.impl;

import com.genghis.core.page.entity.Page;
import com.genghis.core.page.entity.PageParameter;
import com.genghis.ptas.constant.DictConstant;
import com.genghis.ptas.note.dao.NoteDao;
import com.genghis.ptas.note.entity.NoteInfo;
import com.genghis.ptas.note.service.NoteService;
import com.genghis.ptas.scorm.dao.ScormDao;
import com.genghis.ptas.scorm.entity.NodesInfo;
import com.genghis.ptas.scorm.entity.ScormInfo;
import com.genghis.ptas.scorm.entity.UserCourseInfo;
import com.genghis.ptas.scorm.service.UpScormService;
import com.genghis.ptas.security.dao.UserDao;
import com.genghis.ptas.system.service.DictService;
import com.genghis.ptas.util.UploadZipAndUNZip;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.xml.sax.SAXException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: tiangc
 * Date: 14-4-22
 * Time: 下午8:16
 * To change this template use File | Settings | File Templates.
 */
@Transactional
@Service("noteService")
public class NoteServiceImpl implements NoteService {

    @Autowired
    private NoteDao noteDao;

    @Override
    public void addNoteInfo(NoteInfo noteInfo,int userId) {
        noteInfo.setUserId(userId);
       noteDao.addNoteInfo(noteInfo);
    }

    @Override
    public NoteInfo findNoteInfoByScormIdAndUserId(int scormId, int userId) {
        return noteDao.findNoteInfoByScormIdAndUserId(scormId, userId);
    }

    @Override
    public boolean findIsNoteById(int scormId, int userId) {

        int isNote=noteDao.findIsNoteById(scormId, userId);
        if(isNote==0){
            return true;
        }
        return false;
    }

    @Override
    public void editNote(NoteInfo noteInfo,int userId) {
         noteInfo.setUserId(userId);
        noteDao.editNote(noteInfo);
    }
}
